package com.wg.springboot.jdk.lombok;

/**
 * @Description:
 * @Author WuGang
 * @Date 2021/10/25 16:55
 * @Version 1.0
 */
public class CanEquels {
    public static void main(String[] args) {
        Student student = new Student("张三", 30);
        Student student1 = new Student("张三", 30);
        System.out.println(student.equals(student1));
//        当子类没有@data父类有@data  那么子类对象始终true  其他情况则各自判断是否加@data
//        子类属性里面的相同的话，那hashcode的值就相同啦
//        我感觉是因为一个大的包含一个小的  指向了共同的外面大的
        Student2 student2 = new Student2("李四");
        Student2 student3 = new Student2("李四");
        System.out.println(student2.equals(student3));
        System.out.println(student.equals(student2));
//        以下三个 当只重写父类时  都是TRUE  当只重写子类或者都重写时只有第一个是TRUE
        Student student4 = new Student2();
        Student2 student5 = new Student2();
        Student student6 = new Student();
        System.out.println(student4.equals(student5));
        System.out.println(student4.equals(student6));
        System.out.println(student5.equals(student6));
//        要想子类判断结果和我们预计一样那就子类@data  要想父类和我们预计一样就父类@data  当同时存在就只当做有子类存在
        Student2 student21 = new Student2("张三", 30, "1");
        Student2 student22 = new Student2("张三", 3, "1");
        System.out.println(student21.equals(student22));

    }
}
